﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Microsoft.SharePoint;
using Microsoft.SharePoint.UserCode;

namespace SharePointOnlineCustomWorkflowActions
{
    class CreateSiteSimple
    {

        public Hashtable CreateSite(SPUserCodeWorkflowContext context, string siteName)
        {
            Hashtable results = new Hashtable();
            try
            {
                using (SPSite site = new SPSite(context.CurrentWebUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.Webs.Add(siteName,
                              siteName,
                              string.Empty,
                              1033,
                              "STS",
                              false,
                              false);
                    }
                }
                results["success"] = true;
                results["exception"] = string.Empty;
            }
            catch (Exception e)
            {
                results = new Hashtable();
                results["exception"] = e.ToString();
                results["success"] = false;
            }
            return results;
        }
    }

}

